package com.yisoo.rs.rsmovie.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.yisoo.rs.common.utils.MyBeanUtils;
import com.yisoo.rs.common.vo.MovieJsonVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 
 * 
 * @author mmciel
 * @email 761998179@qq.com
 * @date 2021-12-03 17:03:58
 */
@Data
@TableName("movies_movies")
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class MoviesEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 电影ID
	 */
	@TableId
	private Long mvId;
	/**
	 * 所属应用
	 */
	private Long appId;
	/**
	 * 电影名字
	 */
	private String mvName;
	/**
	 * 国家
	 */
	private String mvRegion;
	/**
	 * 发行时间
	 */
	private Integer mvRelease;
	/**
	 * 时长
	 */
	private Integer mvLength;
	/**
	 * 平均评分
	 */
	private Double mvScore;
	/**
	 * 电影排名
	 */
	private Integer mvTop;
	/**
	 * 电影介绍
	 */
	private String mvIntroduce;
	/**
	 * 电影图片
	 */
	private String mvImageUrl;
	/**
	 * 英文名称
	 */
	private String mvEnName;
	/**
	 * 豆瓣id（https://movie.douban.com/subject/）
	 */
	private Long mvDoubanId;
	/**
	 * 图片二进制数据
	 */
	private byte[] mvImage;

	public static List<MoviesEntity> generatorByMovieJsonVo(Long appId, List<MovieJsonVo> dataList){
		return dataList.stream().map(temp -> new MoviesEntity(appId, temp)).collect(Collectors.toList());
	}
	public static List<MoviesEntity> generatorByMovieJsonVo_bak(Long appId, List<MovieJsonVo> dataList, Map<String,Integer> reIndex){
		List<MoviesEntity> collect = dataList.stream().map(temp -> {
			return new MoviesEntity(appId, temp);
		}).collect(Collectors.toList());
		for (int i=0;i<collect.size();i++){
			reIndex.put(collect.get(i).getMvName(),i);
		}
		return collect;
	}
	public MoviesEntity(Long appId, MovieJsonVo movieJsonVo){
		this.mvId = null;
		this.appId = appId;
		this.mvName = movieJsonVo.getMvName();
		this.mvRegion = movieJsonVo.getMvRegion();
		this.mvRelease = movieJsonVo.getMvRelease();
		this.mvLength = movieJsonVo.getMvLength();
		this.mvScore = movieJsonVo.getMvScore();
		this.mvTop = Integer.valueOf(movieJsonVo.getMvTop());
		this.mvIntroduce = null;
		this.mvImageUrl = movieJsonVo.getMvImageUrl();
		this.mvEnName = movieJsonVo.getMvEnName();
		this.mvDoubanId = Long.valueOf(movieJsonVo.getMvDoubanId());
		this.mvImage = null;
	}
}
